//package com.sztz.filter;
//
//import cn.hutool.core.util.StrUtil;
//import lombok.extern.slf4j.Slf4j;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.security.authentication.AuthenticationManager;
//import org.springframework.security.authentication.BadCredentialsException;
//import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
//import org.springframework.security.core.Authentication;
//import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter;
//import org.springframework.security.web.util.matcher.AntPathRequestMatcher;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//
///**
// * 登录认证过滤器
// * @author yzy
// * @date 2023/3/21 19:09
// */
//@Slf4j
//public class LoginAuthenticationFilter extends AbstractAuthenticationProcessingFilter {
//
//    public LoginAuthenticationFilter() {
//        super(new AntPathRequestMatcher("/login","POST"));
//    }
//
//    @Override
//    public Authentication attemptAuthentication(HttpServletRequest request, HttpServletResponse response) {
//        String username = request.getParameter("username");
//        String password = request.getParameter("password");
//        if(StrUtil.hasBlank(username,password)){
//            throw new BadCredentialsException("用户名密码不能为空");
//        }
//        log.info("{}登录请求",username);
//        UsernamePasswordAuthenticationToken usernamePasswordAuthenticationToken = new UsernamePasswordAuthenticationToken(username,password);
//        return getAuthenticationManager().authenticate(usernamePasswordAuthenticationToken);
//    }
//
//    @Autowired
//    @Override
//    public void setAuthenticationManager(AuthenticationManager authenticationManager) {
//        super.setAuthenticationManager(authenticationManager);
//    }
//
//}
